package jxcmanager.jxc.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

/**
 * MyBatisPlus配置类
 */
@SpringBootConfiguration
public class MybatisPlusConfig {
    /**
     * 开启MybatisPlus的分页环境
     *
     * @return
     */
    @Bean
    public MybatisPlusInterceptor paginationInnerInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        //把实现分页的PaginationInnerInterceptor添加到MybatisPlus的拦截器中,DbType.MYSQL代表引用的数据库类型
        return mybatisPlusInterceptor;
    }
}
